import VueRouter from 'vue-router'
import Vue from 'vue'
import HomeViewCom from '@/views/HomeViewCom'
import PlusViewCom from '@/views/PlusViewCom'
import KitchenViewCom from '@/views/KitchenViewCom'
import MoreViewCom from '@/views/MoreViewCom'
import HomeCookingCom from '@/components/home-navbar-view/HomeCookingCom'
import LatestRecipesCom from '@/components/home-navbar-view/LatestRecipesCom'
import PopularRecipesCom from '@/components/home-navbar-view/PopularRecipesCom'
import VideoRecipesCom from '@/components/home-navbar-view/VideoRecipesCom'
import ClassificationView from '@/components/classification-search/SearchFoot'
import EveryFoot from '@/components/classification-search/EveryFoot'
import BookMark from '@/components/mine-more/BookMark'
// 引入轮播图详情组件
import BannerDetail from '@/components/home-view/BannerDetail'
// 引入视频菜谱详情组件
import VideoPlayCom from '@/components/media/VideoPlayCom'
//引入更多页面的关于我们
import AboutUs from '@/components/mine-more/AboutUs'
//引入更多页面用户反馈
import UserFeedback from '@/components/feedback/UserFeedback.vue'
//引入注册页面
import RegisterCom from '@/components/mine-more/RegisterCom'
//用户反馈详情页面
import InfoContent from '@/components/feedback/InfoContent.vue'
//反馈历史记录
import HistoryFeedback from '@/components/feedback/HistoryFeedback.vue'
//反馈热门问题
import HotProblem from '@/components/feedback/HotProblem.vue'
//更多页面的历史记录页面
import HistoricalHistory from '@/components/mine-more/HistoricalHistory'
//登录页面的账号登陆页面
import Login from '@/components/mine-more/AccountLogin'

Vue.use(VueRouter)

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, resolve, reject) {
  if (resolve || reject) return originalPush.call(this, location, resolve, reject)
  return originalPush.call(this, location).catch(() => {})
}

const routes = [
  { path: '/', name: 'app', redirect: '/home' },
  // 首页路由规则
  { path: '/home', name: 'home', component: HomeViewCom },
  //加号页面路由规则
  { path: '/classification', name: 'classification', component: PlusViewCom },
  // 消息页面路由规则
  { path: '/kitchen', name: 'kitchen', component: KitchenViewCom },
  // 我的路由规则
  { path: '/more', name: 'user', component: MoreViewCom },
  // 视频菜谱路由规则
  { path: '/videorecipes', name: 'videorecipes', component: VideoRecipesCom },
  // 最新菜谱路由规则
  { path: '/latestrecipes', name: 'latestrecipes', component: LatestRecipesCom },
  // 热门菜谱路由规则
  { path: '/popularrecipes', name: 'popularrecipes', component: PopularRecipesCom },
  // 家常菜路由规则
  { path: '/homerecipes', name: 'homerecipes', component: HomeCookingCom },
  // 分类页面搜索路由
  { path: '/classificationsearch', name: 'classificationsearch', component: ClassificationView },
  { path: '/evertfoot/:id', name: 'evertfoot', component: EveryFoot },
  // 更多页面的菜谱收藏
  { path: '/bookmark', name: 'bookmark', component: BookMark },
  // 轮播图菜单详情路由规则
  { path: '/banner/:id', name: 'banner', component: BannerDetail, props: true },
  // 视频菜谱详情跳转链接
  { path: '/videodetail/:id', name: 'videodetail', component: VideoPlayCom, props: true },
  //用户反馈详情
  { path: '/infoContent', name: 'infoContent', component: InfoContent },
  //反馈历史页面
  { path: '/historyfeedback', name: 'historyfeedback', component: HistoryFeedback },
  //反馈热门问题
  { path: '/hotproblem', name: 'hotproblem', component: HotProblem },
  // 更多页面的关于我们
  { path: '/aboutus', name: 'aboutus', component: AboutUs },
  //更多页面用户反馈
  { path: '/userfeedback', name: 'userfeedback', component: UserFeedback },
  // 注册页面
  { path: '/register', name: 'promptlogin', component: RegisterCom },
  // 历史记录页面
  { path: '/historicalhistory', name: 'historicalhistory', component: HistoricalHistory },
  //登录页面
  { path: '/login', name: 'login', component: Login }
]

const router = new VueRouter({
  routes
})

export default router
